package com.spring.sunflower.common;

import com.spring.sunflower.base.BaseObserver;
import com.spring.sunflower.base.BasePresenter;
import com.spring.sunflower.bean.FansBean;
import com.spring.sunflower.bean.CommonBean;

import io.reactivex.rxjava3.core.Observable;

/**
 * Created by Kevin on 2021/7/16<br/>
 * <p>
 * Describe:<br/>
 */
public class RelationPresenter extends BasePresenter<CommonContract.RelationView> {
    public RelationPresenter(CommonContract.RelationView baseView) {
        super(baseView);
    }

    public void getFansOrFollowed(String userId, String pageIndex, String type) {
        Observable<FansBean> observable = requestDataSource.requestFansOrFollowed(userId, pageIndex, type);
        addDisposable(observable, new BaseObserver<FansBean>(baseView) {

            @Override
            public void onSuccess(FansBean bean) {
                baseView.showRelationList(bean.getDatas());
            }

            @Override
            public void onError(int status, String msg) {

            }
        });
    }
    public void setFollowed(String anchorId, String set) {
        Observable<CommonBean> observable = requestDataSource.requestFollowedSet(anchorId, set);
        addDisposable(observable, new BaseObserver<CommonBean>(baseView) {

            public void onSuccess(CommonBean bean) {
                baseView.setFollowedSuccess();
            }

            @Override
            public void onError(int status, String msg) {
                baseView.setFollowedFailed();
            }
        });
    }
}
